/*
 * Copyright 2018-2019 Expedia Group, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.expedia.adaptivealerting.anomdetect.detect.outlier;

import com.expedia.adaptivealerting.anomdetect.detect.AnomalyLevel;
import com.expedia.adaptivealerting.anomdetect.detect.AnomalyThresholds;
import com.expedia.adaptivealerting.anomdetect.detect.DetectorResult;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

// TODO Change to an interface, and use an abstract base class for the impl. That will bring it into alignment with
//  the BreakoutDetectorResult. [WLW]

/**
 * Result generated by outlier detectors.
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class OutlierDetectorResult implements DetectorResult {
    private boolean warmup;
    private boolean trusted;
    private AnomalyLevel anomalyLevel;

    /**
     * Point forecast.
     */
    private Double predicted;

    /**
     * Interval forecast.
     */
    private AnomalyThresholds thresholds;

    public OutlierDetectorResult(AnomalyLevel anomalyLevel) {
        // TODO: Do this instead while there are still deprecated usages of AnomalyLevel.MODEL_WARMUP
        // this(MODEL_WARMUP.equals(anomalyLevel), MODEL_WARMUP.equals(anomalyLevel) ? UNKNOWN : anomalyLevel);
        this(false, anomalyLevel);    }

    public OutlierDetectorResult(boolean warmup, AnomalyLevel anomalyLevel) {
        this.warmup = warmup;
        this.anomalyLevel = anomalyLevel;
    }

    public OutlierDetectorResult(AnomalyLevel anomalyLevel, boolean trusted) {
        this.trusted = trusted;
        this.anomalyLevel = anomalyLevel;
    }

    public OutlierDetectorResult(boolean warmup, AnomalyLevel anomalyLevel, boolean trusted) {
        this.warmup = warmup;
        this.trusted = trusted;
        this.anomalyLevel = anomalyLevel;
    }
}
